package com.tvunetworks.center.device.service;

import com.tvunetworks.center.common.model.dto.MsgpipeDTO;
import com.tvunetworks.center.common.model.param.PeerIdParam;
import com.tvunetworks.center.common.model.vo.TimeLockDeviceMsgVo;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.device.model.TimeLockEvent;
import com.tvunetworks.center.device.model.param.TimeLockSyncParam;
import com.tvunetworks.center.device.model.param.TimeLockUpdateSyncParam;
import com.tvunetworks.center.device.model.vo.DeviceIdNameAndMsg;
import com.tvunetworks.center.device.model.vo.TimeLockMsgResult;

import java.util.List;
import java.util.Map;
/**
 * @author Etan Yang
 * @create: 2021/10/13 15:27
 */
public interface TimeLockEventService {
    /**
     * 打开timeLock
     * @param userId 用户id
     * @param param R/Pack
     * @return 返回状态
     */
    Result<String> synchronize(String userId, TimeLockSyncParam param);

    /**
     * 更新TimeLock
     * @param userId 用户id
     * @param param 更新timeLock的参数
     *  @param  role role
     */
    void updateSynchronize(String userId, TimeLockUpdateSyncParam param,String role);

    /**
     *
     * @param userId 解绑TimeLock
     * @return Result
     */
    Result<String> unSynchronize(String userId);

    /**
     * R端取消Sync
     * @param rid rid
     * @param needSendMsgpipe 是否需要发送msgPipe
     *   @param userId userId
     */
    void cancelSync(String rid, boolean needSendMsgpipe,String userId);

    /**
     * 给R发送信息
     * @param peerId peerId
     * @param eventId  eventId
     * @param status status
     * @return Result
     */
    Result<String> receiveMsg(String peerId, String eventId, int status);

    /**
     * 检查设备的TimeLock状态
     * @param userId userId
     * @param peerIds peerIds
     * @return Result
     */
    Result<String> checkDevieTimeLockStatus(String userId, String peerIds);

    /**
     *
     * @param peerIds peerIds
     * @param bitRate bitRate
     * @param delay delay
     * @return List
     */
    List<DeviceIdNameAndMsg> setBitrateAndDelay(String peerIds, int bitRate, int delay);

    /**
     * 解除设备的TimeLock
     * @param userId userId
     * @param peerIds peerIds
     * @return Result
     */
    Result<String> removeSyn(String userId, String peerIds);

    /**
     * 批量查询设备的TimeLock状态
     * @param userId userId
     * @param peerIdList peerIdList
     * @return List
     */
    List<TimeLockMsgResult> checkDevieTimeLockStatus(String userId, List<String> peerIdList);

    /**
     *
     * @param message message
     */
    void processTimeLockMessage(MsgpipeDTO message);

    /**
     * 根据userId获取该用户下正在执行TimeLock的Receiver
     * @param rids rid集合
     * @return 返回正在TimeLock的Receiver
     */
    List<TimeLockDeviceMsgVo> listOpenTimeLockReceiverByRids(List<String> rids);

    /**
     * 根据Rid获取该用户下正在执行TimeLock的Pack
     * @param rids rid集合
     * @return 返回正在TimeLock的Pack
     */
    List<TimeLockDeviceMsgVo> listOpenTimeLockPackByRids(List<String> rids);

    /**
     * 根据peerId获取用户信息和所有同步R的信息
     * @param param  param
     * @return Map
     */
    Map<String,Object> getTimeLockMsgByPeerId(PeerIdParam param);

    /**
     * 获取所有同步R的信息
     * @return 同步R的信息
     */
    List<TimeLockDeviceMsgVo> getAllReceiverTimeLockMsg();


    /**
     * 接口已废弃
     * 根据rid的集合获取正在timeLock的Pack
     * @param userId userId
     * @return 返回同步Pack的信息
     */
    List<TimeLockDeviceMsgVo> listOpenTimeLockPackByUserId(String userId);


    /**
     * 根据主键获取timeLock信息
     * @param eventId 主键id
     * @return 返回timeLockEvent的信息
     */
    TimeLockEvent getTimeLockEventById(String eventId);
}
